<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html lang="en">

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
  <title>LCOV - cover.info - /home/andres/Programacion/aso_coverage/aso/src/ASO/framework/antiviral_imp.cpp</title>
  <link rel="stylesheet" type="text/css" href="../../../../../../../../gcov.css">
</head>

<body>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
    <tr><td class="title">LCOV - code coverage report</td></tr>
    <tr><td class="ruler"><img src="../../../../../../../../glass.png" width=3 height=3 alt=""></td></tr>

    <tr>
      <td width="100%">
        <table cellpadding=1 border=0 width="100%">
        <tr>
          <td width="5%"></td>
          <td width="10%" class="headerItem">Current view:</td>
          <td width="35%" class="headerValue"><a href="../../../../../../../../index.html">directory</a> - <a href="index.html">home/andres/Programacion/aso_coverage/aso/src/ASO/framework</a> - antiviral_imp.cpp (source / <a href="antiviral_imp.cpp.func.html">functions</a>)</td>
          <td width="10%"></td>
          <td width="10%" class="headerCovTableHead">Found</td>
          <td width="10%" class="headerCovTableHead">Hit</td>
          <td width="15%" class="headerCovTableHead">Coverage</td>
          <td width="5%"></td>
        </tr>
        <tr>
          <td></td>
          <td class="headerItem">Test:</td>
          <td class="headerValue">cover.info</td>
          <td class="headerItem">Lines:</td>
          <td class="headerCovTableEntry">107</td>
          <td class="headerCovTableEntry">95</td>
          <td class="headerCovTableEntryHi">88.8 %</td>
        </tr>
        <tr>
          <td></td>
          <td class="headerItem">Date:</td>
          <td class="headerValue">2010-08-03</td>
          <td class="headerItem">Functions:</td>
          <td class="headerCovTableEntry">15</td>
          <td class="headerCovTableEntry">13</td>
          <td class="headerCovTableEntryMed">86.7 %</td>
        </tr>
                <tr><td><img src="../../../../../../../../glass.png" width=3 height=3 alt=""></td></tr>
        </table>
      </td>
    </tr>
    <tr><td class="ruler"><img src="../../../../../../../../glass.png" width=3 height=3 alt=""></td></tr>
  </table>

  <table cellpadding=0 cellspacing=0 border=0>
    <tr>
      <td><br></td>
    </tr>
    <tr>
      <td><pre class="source">
<a name="1"><span class="lineNum">       1 </span>                : /**</a>
<span class="lineNum">       2 </span>                :  * \file  antiviral.cpp
<span class="lineNum">       3 </span>                :  * \brief implementation of Antiviral class.
<span class="lineNum">       4 </span>                :  *
<span class="lineNum">       5 </span>                :  * ASO: Antiviral Sequence Optimizer
<span class="lineNum">       6 </span>                :  * &lt;http://aso.googlecode.com/&gt;
<span class="lineNum">       7 </span>                :  * Copyright (C) 2010 Velez Ezequiel, Peralta Andres, FuDePAN
<span class="lineNum">       8 </span>                :  *
<span class="lineNum">       9 </span>                :  * This file is part of the ASO project.
<span class="lineNum">      10 </span>                :  *
<span class="lineNum">      11 </span>                :  * Contents:      CPP file for ASO providing class Antiviral.
<span class="lineNum">      12 </span>                :  *
<span class="lineNum">      13 </span>                :  * System:         ASO
<span class="lineNum">      14 </span>                :  * Language:       C++
<span class="lineNum">      15 </span>                :  *
<span class="lineNum">      16 </span>                :  * Author:         Velez Ezequiel, Peralta Andres
<span class="lineNum">      17 </span>                :  * E-Mail:
<span class="lineNum">      18 </span>                :  *
<span class="lineNum">      19 </span>                :  * ASO is free software: you can redistribute it and/or modify
<span class="lineNum">      20 </span>                :  * it under the terms of the GNU General Public License as published by
<span class="lineNum">      21 </span>                :  * the Free Software Foundation, either version 3 of the License, or
<span class="lineNum">      22 </span>                :  * (at your option) any later version.
<span class="lineNum">      23 </span>                :  *
<span class="lineNum">      24 </span>                :  * ASO is distributed in the hope that it will be useful,
<span class="lineNum">      25 </span>                :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
<span class="lineNum">      26 </span>                :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
<span class="lineNum">      27 </span>                :  * GNU General Public License for more details.
<span class="lineNum">      28 </span>                :  *
<span class="lineNum">      29 </span>                :  * You should have received a copy of the GNU General Public License
<span class="lineNum">      30 </span>                :  * along with ASO.  If not, see &lt;http://www.gnu.org/licenses/&gt;.
<span class="lineNum">      31 </span>                :  *
<span class="lineNum">      32 </span>                :  */
<span class="lineNum">      33 </span>                : 
<span class="lineNum">      34 </span>                : #include &quot;antiviral_imp.h&quot;
<span class="lineNum">      35 </span>                : 
<a name="36"><span class="lineNum">      36 </span>                : using namespace std;</a>
<span class="lineNum">      37 </span>                : 
<span class="lineNum">      38 </span><span class="lineCov">             63 : std::ostream&amp; operator&lt;&lt; (std::ostream &amp;out, const AvType&amp; atype)</span>
<span class="lineNum">      39 </span>                : {
<span class="lineNum">      40 </span><span class="lineCov">             63 :     switch (atype)</span>
<span class="lineNum">      41 </span>                :     {
<span class="lineNum">      42 </span>                :         case tRT:
<span class="lineNum">      43 </span><span class="lineCov">              9 :             out &lt;&lt; &quot;tRT&quot;;</span>
<span class="lineNum">      44 </span><span class="lineCov">              9 :             break;</span>
<span class="lineNum">      45 </span>                :         case tPI:
<span class="lineNum">      46 </span><span class="lineCov">              6 :             out &lt;&lt; &quot;tPI&quot;;</span>
<span class="lineNum">      47 </span><span class="lineCov">              6 :             break;</span>
<span class="lineNum">      48 </span>                :         case tComb:
<span class="lineNum">      49 </span><span class="lineCov">             48 :             out &lt;&lt; &quot;tComb&quot;;</span>
<span class="lineNum">      50 </span><span class="lineCov">             48 :             break;</span>
<span class="lineNum">      51 </span>                :         default:
<span class="lineNum">      52 </span><span class="lineNoCov">              0 :             out.setstate(std::ios::failbit); //set error bit in is</span>
<span class="lineNum">      53 </span>                :     }
<span class="lineNum">      54 </span><span class="lineCov">             63 :     return out;</span>
<a name="55"><span class="lineNum">      55 </span>                : }</a>
<span class="lineNum">      56 </span>                : 
<span class="lineNum">      57 </span><span class="lineCov">             63 : std::ostream&amp; operator&lt;&lt; (std::ostream &amp;out, const AvClass&amp; aclass)</span>
<span class="lineNum">      58 </span>                : {
<span class="lineNum">      59 </span><span class="lineCov">             63 :     switch (aclass)</span>
<span class="lineNum">      60 </span>                :     {
<span class="lineNum">      61 </span>                :         case cPI:
<span class="lineNum">      62 </span><span class="lineCov">              6 :             out &lt;&lt; &quot;cPI&quot;;</span>
<span class="lineNum">      63 </span><span class="lineCov">              6 :             break;</span>
<span class="lineNum">      64 </span>                :         case cNRTI:
<span class="lineNum">      65 </span><span class="lineCov">              6 :             out &lt;&lt; &quot;cNRTI&quot;;</span>
<span class="lineNum">      66 </span><span class="lineCov">              6 :             break;</span>
<span class="lineNum">      67 </span>                :         case cNNRTI:
<span class="lineNum">      68 </span><span class="lineCov">              3 :             out &lt;&lt; &quot;cNNRTI&quot;;</span>
<span class="lineNum">      69 </span><span class="lineCov">              3 :             break;</span>
<span class="lineNum">      70 </span>                :         case cComb:
<span class="lineNum">      71 </span><span class="lineCov">             48 :             out &lt;&lt; &quot;cComb&quot;;</span>
<span class="lineNum">      72 </span><span class="lineCov">             48 :             break;</span>
<span class="lineNum">      73 </span>                :         default:
<span class="lineNum">      74 </span><span class="lineNoCov">              0 :             out.setstate(std::ios::failbit); //set error bit in is</span>
<span class="lineNum">      75 </span>                :     }
<span class="lineNum">      76 </span><span class="lineCov">             63 :     return out;</span>
<a name="77"><span class="lineNum">      77 </span>                : }</a>
<span class="lineNum">      78 </span>                : 
<span class="lineNum">      79 </span><span class="lineCov">             15 : std::istream&amp; operator&gt;&gt; (std::istream&amp; is, AvType&amp; atype)</span>
<span class="lineNum">      80 </span>                : {
<span class="lineNum">      81 </span><span class="lineCov">             15 :     string s;</span>
<span class="lineNum">      82 </span>                : 
<span class="lineNum">      83 </span><span class="lineCov">             15 :     if (is &gt;&gt; s)</span>
<span class="lineNum">      84 </span>                :     {
<span class="lineNum">      85 </span><span class="lineCov">             15 :         if (s == &quot;tRT&quot;)</span>
<span class="lineNum">      86 </span><span class="lineCov">              9 :             atype = tRT;</span>
<span class="lineNum">      87 </span><span class="lineCov">              6 :         else if (s == &quot;tPI&quot;)</span>
<span class="lineNum">      88 </span><span class="lineCov">              6 :             atype = tPI;</span>
<span class="lineNum">      89 </span><span class="lineNoCov">              0 :         else if (s == &quot;tComb&quot;)</span>
<span class="lineNum">      90 </span><span class="lineNoCov">              0 :             atype = tComb;</span>
<span class="lineNum">      91 </span>                :         else
<span class="lineNum">      92 </span><span class="lineNoCov">              0 :             is.setstate(std::ios::failbit); //set error bit in is</span>
<span class="lineNum">      93 </span>                :     }
<span class="lineNum">      94 </span><span class="lineCov">             15 :     return is;</span>
<a name="95"><span class="lineNum">      95 </span>                : }</a>
<span class="lineNum">      96 </span>                : 
<span class="lineNum">      97 </span><span class="lineCov">             15 : std::istream&amp; operator&gt;&gt; (std::istream&amp; is, AvClass&amp; aclass)</span>
<span class="lineNum">      98 </span>                : {
<span class="lineNum">      99 </span><span class="lineCov">             15 :     string s;</span>
<span class="lineNum">     100 </span>                : 
<span class="lineNum">     101 </span><span class="lineCov">             15 :     if (is &gt;&gt; s)</span>
<span class="lineNum">     102 </span>                :     {
<span class="lineNum">     103 </span><span class="lineCov">             15 :         if (s == &quot;cPI&quot;)</span>
<span class="lineNum">     104 </span><span class="lineCov">              6 :             aclass = cPI;</span>
<span class="lineNum">     105 </span><span class="lineCov">              9 :         else if (s == &quot;cNRTI&quot;)</span>
<span class="lineNum">     106 </span><span class="lineCov">              6 :             aclass = cNRTI;</span>
<span class="lineNum">     107 </span><span class="lineCov">              3 :         else if (s == &quot;cNNRTI&quot;)</span>
<span class="lineNum">     108 </span><span class="lineCov">              3 :             aclass = cNNRTI;</span>
<span class="lineNum">     109 </span><span class="lineNoCov">              0 :         else if (s == &quot;cComb&quot;)</span>
<span class="lineNum">     110 </span><span class="lineNoCov">              0 :             aclass = cComb;</span>
<span class="lineNum">     111 </span>                :         else
<span class="lineNum">     112 </span><span class="lineNoCov">              0 :             is.setstate(std::ios::failbit); //set error bit in is</span>
<span class="lineNum">     113 </span>                :     }
<span class="lineNum">     114 </span><span class="lineCov">             15 :     return is;</span>
<a name="115"><span class="lineNum">     115 </span>                : }</a>
<span class="lineNum">     116 </span>                : 
<span class="lineNum">     117 </span><span class="lineCov">             53 : void ResisBasedAntiviral::combine_with(ResisBasedAntiviral&amp; other) const</span>
<span class="lineNum">     118 </span>                : {
<span class="lineNum">     119 </span><span class="lineCov">             53 :     CAutonomousIterator&lt;ResisBasedAntiviral::Resistances&gt; it(resistances);</span>
<span class="lineNum">     120 </span>                : 
<span class="lineNum">     121 </span><span class="lineCov">            413 :     while (!it.end())</span>
<span class="lineNum">     122 </span>                :     {
<span class="lineNum">     123 </span><span class="lineCov">            413 :         size_t pos_temp = it-&gt;pos;</span>
<span class="lineNum">     124 </span><span class="lineCov">            413 :         std::string amin_temp = it-&gt;aminoacids;</span>
<span class="lineNum">     125 </span>                : 
<span class="lineNum">     126 </span><span class="lineCov">            413 :         AutonomousIterator&lt;ResisBasedAntiviral::Resistances&gt; it2(other.resistances);</span>
<span class="lineNum">     127 </span><span class="lineCov">            413 :         bool found(false);</span>
<span class="lineNum">     128 </span>                : 
<span class="lineNum">     129 </span><span class="lineCov">           4286 :         while (!it2.end())</span>
<span class="lineNum">     130 </span>                :         {
<span class="lineNum">     131 </span><span class="lineCov">           3460 :             if (pos_temp == it2-&gt;pos)</span>
<span class="lineNum">     132 </span>                :             {
<span class="lineNum">     133 </span><span class="lineNoCov">              0 :                 for (size_t i = 0; i &lt; amin_temp.size(); ++i)</span>
<span class="lineNum">     134 </span>                :                 {
<span class="lineNum">     135 </span><span class="lineNoCov">              0 :                     if (!is_in(amin_temp[i], it2-&gt;aminoacids))</span>
<span class="lineNum">     136 </span>                :                     {
<span class="lineNum">     137 </span><span class="lineNoCov">              0 :                         it2-&gt;aminoacids += amin_temp[i];</span>
<span class="lineNum">     138 </span>                :                     }
<span class="lineNum">     139 </span>                :                 }
<span class="lineNum">     140 </span><span class="lineNoCov">              0 :                 found = true;</span>
<span class="lineNum">     141 </span>                :             }
<span class="lineNum">     142 </span><span class="lineCov">           3460 :             ++it2;</span>
<span class="lineNum">     143 </span>                :         }
<span class="lineNum">     144 </span><span class="lineCov">            413 :         if (!found) other.add_resistance(pos_temp, amin_temp);</span>
<span class="lineNum">     145 </span><span class="lineCov">            413 :         ++it;</span>
<span class="lineNum">     146 </span>                :     }
<a name="147"><span class="lineNum">     147 </span><span class="lineCov">             53 : }</span></a>
<span class="lineNum">     148 </span>                : 
<span class="lineNum">     149 </span><span class="lineCov">             39 : void ResisBasedAntiviral::mutate_sequence(const NucSequence&amp; sequence, MutantDist&amp; mutations) const</span>
<span class="lineNum">     150 </span>                : {
<span class="lineNum">     151 </span><span class="lineCov">             39 :     float min_dist = applies(sequence);</span>
<span class="lineNum">     152 </span><span class="lineCov">             39 :     if (min_dist &gt; 0.0)</span>
<span class="lineNum">     153 </span>                :     {
<span class="lineNum">     154 </span><span class="lineCov">             24 :         CAutonomousIterator&lt;Resistances&gt; it(resistances);</span>
<span class="lineNum">     155 </span>                : 
<span class="lineNum">     156 </span><span class="lineCov">            413 :         while (!it.end())</span>
<span class="lineNum">     157 </span>                :         {
<span class="lineNum">     158 </span><span class="lineCov">            413 :             TripletVal tv = it-&gt;min_dist_to_resistance(sequence);</span>
<span class="lineNum">     159 </span><span class="lineCov">            413 :             float min_val = tv.second;</span>
<span class="lineNum">     160 </span><span class="lineCov">            413 :             TripletList triplets = tv.first;</span>
<span class="lineNum">     161 </span><span class="lineCov">            413 :             CAutonomousIterator&lt;TripletList&gt; trip_iter(triplets);</span>
<span class="lineNum">     162 </span>                : 
<span class="lineNum">     163 </span><span class="lineCov">           1038 :             while (!trip_iter.end())</span>
<span class="lineNum">     164 </span>                :             {
<span class="lineNum">     165 </span><span class="lineCov">            625 :                 NucSequence mutation = sequence;</span>
<span class="lineNum">     166 </span><span class="lineCov">            625 :                 if (min_dist == min_val)</span>
<span class="lineNum">     167 </span>                :                 {
<span class="lineNum">     168 </span><span class="lineCov">            394 :                     mutation.set_triplet(it-&gt;pos, *trip_iter);</span>
<span class="lineNum">     169 </span><span class="lineCov">            394 :                     insert_into(mutations.sequences, mutation);</span>
<span class="lineNum">     170 </span>                :                 }
<span class="lineNum">     171 </span><span class="lineCov">            625 :                 ++trip_iter;</span>
<span class="lineNum">     172 </span>                :             }
<span class="lineNum">     173 </span><span class="lineCov">            413 :             ++it;</span>
<span class="lineNum">     174 </span>                :         }
<span class="lineNum">     175 </span><span class="lineCov">             24 :         mutations.distance = min_dist;</span>
<span class="lineNum">     176 </span>                :     }
<a name="177"><span class="lineNum">     177 </span><span class="lineCov">             39 : }</span></a>
<span class="lineNum">     178 </span>                : 
<span class="lineNum">     179 </span><span class="lineCov">           4734 : float ResisBasedAntiviral::applies(const NucSequence&amp; sequence) const</span>
<span class="lineNum">     180 </span>                : {
<span class="lineNum">     181 </span><span class="lineCov">           4734 :     float min_dist(3.0f);</span>
<span class="lineNum">     182 </span>                : 
<span class="lineNum">     183 </span><span class="lineCov">           4734 :     CAutonomousIterator&lt;Resistances&gt; it(resistances);</span>
<span class="lineNum">     184 </span>                : 
<span class="lineNum">     185 </span><span class="lineCov">          38407 :     while (!it.end())</span>
<span class="lineNum">     186 </span>                :     {
<span class="lineNum">     187 </span><span class="lineCov">          38407 :         TripletVal triplets_val = it-&gt;min_dist_to_resistance(sequence);</span>
<span class="lineNum">     188 </span><span class="lineCov">          38407 :         min_dist = minimize(min_dist, triplets_val.second);</span>
<span class="lineNum">     189 </span><span class="lineCov">          38407 :         ++it;</span>
<span class="lineNum">     190 </span>                :     }
<span class="lineNum">     191 </span><span class="lineCov">           4734 :     return min_dist;</span>
<a name="192"><span class="lineNum">     192 </span>                : }</a>
<span class="lineNum">     193 </span>                : 
<span class="lineNum">     194 </span><span class="lineCov">            534 : ResisBasedAntiviral&amp; ResisBasedAntiviral::add_resistance(size_t pos, const std::string&amp; aminoacids)</span>
<span class="lineNum">     195 </span>                : {
<span class="lineNum">     196 </span><span class="lineCov">            534 :     insert_into(resistances, ResistancePosition(pos, tolower(aminoacids)));</span>
<span class="lineNum">     197 </span><span class="lineCov">            534 :     return *this;</span>
<a name="198"><span class="lineNum">     198 </span>                : }</a>
<span class="lineNum">     199 </span>                : 
<span class="lineNum">     200 </span><span class="lineCov">              3 : ResisBasedAntiviral&amp; ResisBasedAntiviral::add_attribute(const std::string&amp; attrib, const std::string&amp; value)</span>
<span class="lineNum">     201 </span>                : {
<span class="lineNum">     202 </span><span class="lineCov">              3 :     set_attrib(attrib, value);</span>
<span class="lineNum">     203 </span><span class="lineCov">              3 :     return *this;</span>
<a name="204"><span class="lineNum">     204 </span>                : }</a>
<span class="lineNum">     205 </span>                : 
<span class="lineNum">     206 </span><span class="lineCov">             15 : void ResisBasedAntiviral::print_resistances() const</span>
<span class="lineNum">     207 </span>                : {
<span class="lineNum">     208 </span><span class="lineCov">             15 :     CAutonomousIterator&lt;Resistances&gt; it(resistances);</span>
<span class="lineNum">     209 </span>                : 
<span class="lineNum">     210 </span><span class="lineCov">            151 :     while (!it.end())</span>
<span class="lineNum">     211 </span>                :     {
<span class="lineNum">     212 </span><span class="lineCov">            121 :         std::cout &lt;&lt; &quot;(&quot; &lt;&lt; it-&gt;pos &lt;&lt; &quot;, &quot; &lt;&lt; it-&gt;aminoacids &lt;&lt; &quot;)&quot; &lt;&lt; std::endl;</span>
<span class="lineNum">     213 </span><span class="lineCov">            121 :         ++it;</span>
<span class="lineNum">     214 </span>                :     }
<a name="215"><span class="lineNum">     215 </span><span class="lineCov">             15 : }</span></a>
<span class="lineNum">     216 </span>                : 
<span class="lineNum">     217 </span><span class="lineCov">             15 : void ResisBasedAntiviral::print_antiviral() const</span>
<span class="lineNum">     218 </span>                : {
<span class="lineNum">     219 </span><span class="lineCov">             15 :     std::cout &lt;&lt; &quot;----------Atributos---------- &quot; &lt;&lt; std::endl;</span>
<span class="lineNum">     220 </span><span class="lineCov">             15 :     print_attributes();</span>
<a name="221"><span class="lineNum">     221 </span><span class="lineCov">             15 :     std::cout &lt;&lt; &quot;----------Resistencias----------&quot; &lt;&lt; std::endl;</span></a>
<span class="lineNum">     222 </span><span class="lineCov">             15 :     print_resistances();</span>
<span class="lineNum">     223 </span><span class="lineCov">             18 : }</span>
<span class="lineNum">     224 </span>                : 
</pre>
      </td>
    </tr>
  </table>
  <br>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
  <tr><td class="ruler"><img src="../../../../../../../../glass.png" width=3 height=3 alt=""></td></tr>
  <tr><td class="versionInfo">Generated by: <a href="http://ltp.sourceforge.net/coverage/lcov.php" target="_parent">LCOV version 1.7</a></td></tr>
  </table>
  <br>

</body>
</html>
